﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.Supervise.Model;

namespace HZ.Supervise.Web.PageControl
{
	public partial class Top : BasePage
	{

		HZ.Supervise.IBLL.IBLL_User ibllEntity = BLLFactory.BLL_User();

		/// <summary>
		/// 登录时显示用户名
		/// 董辉
		/// 2011-4-21 16:52
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Page_Load(object sender, EventArgs e)
		{
			User user = new User();

			user = CurrentAccount.GetUser();

			if (user != null)
			{
				CurrentUser = user.UserName;
			}
		}

		/// <summary>
		/// 当前用户名属性
		/// 董辉
		/// 2011-4-21 16:51
		/// </summary>
		public string CurrentUser
		{
			get;
			set;
		}

		protected bool CheckPsw(string operatingName)
		{
			bool flag = false;

			if (CurrentAccount.GetUser().UserID == "root")//超级用户，不加权限控制
			{

				return true;

			}
			else
			{
				IList<HZ.Supervise.Model.OperatingRule> list = ibllEntity.GetUserOperatingRule(CurrentAccount.GetUser().UserID);//得到该用户拥有的所有权限

				foreach (OperatingRule item in list)
				{

					if (item.OperatingRuleName == "密码修改")
					{

						flag = true;

						break;

					}

				}

				return flag;
			}

		}

		/// <summary>
		/// 曹鹏
		/// 2011年4月26日15:29:56 
		/// 权限控制
		/// </summary>
		/// <param name="moduleName"></param>
		/// <returns></returns>
		public string CheckMenuByUserID(string moduleName)
		{
			if (CurrentAccount.GetUser().UserID == "root")//如果是超级管理员，权限全开
			{

				return "";//返回

			}
			else
			{

                string strCheck = " display:none ";//定义一个变量，用来储存将要返回的值

				IList<HZ.Supervise.Model.OperatingRule> list = ibllEntity.GetUserOperatingRule(CurrentAccount.GetUser().UserID);//得到该用户拥有的所有权限


                if (moduleName == "系统管理")
				{
					foreach (HZ.Supervise.Model.OperatingRule itemMenu in list)//遍历
					{

                        if ((itemMenu.Module.ToString() == "用户信息管理"))//匹配
						{

							strCheck = "  " ;

							break;

						}
					}

				}


				return strCheck;

			}

		}

		protected string GetSessionID()
		{

			string sessionid = Guid.NewGuid().ToString();

			SuperviseQuery query = new SuperviseQuery();

			query.CompanyType = 2;

			Session[sessionid] = query;

			return sessionid;
		}
	}
}
